package oop.core.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import oop.core.ai.AI;
import oop.core.ai.AggressiveAI;
import oop.core.item.Equipment;
import oop.core.item.Inventory;
import oop.core.item.ItemLibrary;
import oop.core.item.SellableItem;
import oop.core.map.Location;
import oop.core.map.MovementType;

/**
 * A static library to hold all the entities. 
 */
public class EntityLibrary {
	private static Map<String, Entity> library = new HashMap<String, Entity>();
	private static int numEntitys = 0;
	
	public static int getNumEntitys(){
		return numEntitys;
	}
	
	public static void init()
	{
		List<MovementType> satanmovementTypes = new ArrayList<MovementType>();
		satanmovementTypes.add(MovementType.fly);
		satanmovementTypes.add(MovementType.walk);
		satanmovementTypes.add(MovementType.swim);
		String[] satanS = {"I'm sexy", "I am Satan!"};
		NPC satan = new NPC(null, satanS , true, 10, "satan8", "satan", 8, null, true, null, null, satanmovementTypes , new DerivedStats(0, 1, 200, 0, 50, 50, 50, 50, 50), 100);
		library.put("satan", satan);
		
		List<MovementType> slimemovementTypes = new ArrayList<MovementType>();
		slimemovementTypes.add(MovementType.walk);
		
		String[] slimes = {"Good goo meet you!", " I HATE YOU!"};
		
		NPC slime = new NPC(null, slimes, true, 5, "slime", "slime", 8, null, true, null, null, slimemovementTypes, new DerivedStats(0, 1, 10, 0, 5, 5, 5, 5, 5), 10);
		
		library.put("slime", slime);
		
		List<MovementType> merchmovementTypes = new ArrayList<MovementType>();
		slimemovementTypes.add(MovementType.walk);
		
		String[] merchS = {"Hey stranger, whatcha buyin?", "Hi, I'm Taloon."};
		
		List<SellableItem> toSell = new ArrayList<SellableItem>();
		
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("broadsword1H"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("breadUsable"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("katana1H"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("goldHelm"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("chainmailArmor"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("bowRanged"));
		toSell.add((SellableItem)ItemLibrary.getFromLibrary("thunderStaff"));
		
		MerchantNPC merchant = new MerchantNPC(toSell, null, merchS, true, 5, "merchant", "merchant", 8, null, true, null, null, merchmovementTypes, new DerivedStats(0, 1, 1, 1, 5, 5, 5, 5, 5), 0);
		
		library.put("merchant", merchant);	
	}
	
	public static void addToLibrary(Entity elem, String name)
	{
		if(!library.containsKey(name))
		{
			library.put(name, elem);
			numEntitys++;
		}
	}
	
	/**
	 * This method assumes you filter your removals prior to calling this method. 
	 */
	public static Entity removeEntityFromLibrary(String name)
	{
		Entity elem = library.remove(name);
		numEntitys--;
		return elem;
	}
	
	public static Entity getFromLibrary(String name)
	{
		return library.get(name);
	}
}
